package cn.maxhou.service.impl;

import cn.maxhou.entity.User;
import cn.maxhou.mapper.UserMapper;
import cn.maxhou.service.UserService;
import cn.maxhou.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImpl implements UserService {
    public static SqlSession sqlSession = MyBatisUtil.createSqlSession();
    public static UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
    @Override
    public int insert(User user) {
        int insert = userMapper.insert(user);
        sqlSession.commit();
        return insert;
    }

    @Override
    public int checkusername(String username) {
        int check = userMapper.checkusername(username);
        return check;
    }

    @Override
    public int isUser(String username) {
        return userMapper.isUser(username);
    }

    @Override
    public int isAdmin(String username) {
        return userMapper.isAdmin(username);
    }

    @Override
    public int userlogin(String username, String password) {
        return userMapper.userlogin(username, password);
    }

    @Override
    public int amdinlogin(String username, String password) {
        return userMapper.amdinlogin(username, password);
    }

    @Override
    public User getUser(String username) {
        return userMapper.getUser(username);
    }
}
